import React, { Component, createRef } from "react";

class App extends Component {
  state = {};
  dom = createRef();

  fn = () => {
    console.log(this.dom.current);
  };

  render() {
    return (
      <>
        <h2>ref是可以用来获取dom节点的</h2>
        <div ref={this.dom}>123</div>
        <button onClick={this.fn}>btn</button>
      </>
    );
  }
}

export default App;
